package com.owen.oauth2.client.api;

import org.springframework.social.oauth2.AbstractOAuth2ApiBinding;
import org.springframework.social.oauth2.TokenStrategy;

public class MyOAuth2Impl extends AbstractOAuth2ApiBinding implements MyOAuth2 {
    private final String URL_GET_USERINFO="http://localhost:9001/user";

    public MyOAuth2Impl(String accessToken){
//        super(accessToken);
        super(accessToken, TokenStrategy.ACCESS_TOKEN_PARAMETER);
    }

    @Override
    public MyOAuth2UserInfo getUserInfo() {
        String data = getRestTemplate().getForObject(URL_GET_USERINFO, String.class);
        MyOAuth2UserInfo result=new MyOAuth2UserInfo();
        result.setId(data);
        result.setImageUrl("imageUrl");
        result.setNickName(data);
        result.setProfileUrl("profileUrl");
        return result;
    }
}
